﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using ECG.Common;

namespace ECG.DAL
{
    public partial class GoldenTimeCampainDb
    {

        public static List<GoldenTimeCampainDto> GoldenTimeCampain_GetAdminList()
        {
            var dao = SharedSqlDao;
            var command = dao.GetDbSprocCommand("WSPX_GoldenTimeCampain_GetAdminList");
            try
            {
                return dao.GetDTOList<GoldenTimeCampainDto>(ref command);
            }
            finally
            {
                command.Connection.Close();
            }
        }

        public static int GoldenTimeCampain_UpdateCountProduct(GoldenTimeCampainDto model)
        {
            var dao = SharedSqlDao;
            var command = dao.GetDbSprocCommand("WSPX_GoldenTimeCampain_UpdateCountProduct");
            try
            {
                command.Parameters.Add(dao.CreateParameter("@GoldenTimeId", model.Id));
                command.Parameters.Add(dao.CreateParameter("@CountProduct", model.CountProduct));
                return command.ExecuteNonQuery();
            }
            finally
            {
                command.Connection.Close();
            }
        }

        public static int GoldenTimeCampain_UpdateStatus(GoldenTimeCampainDto model)
        {
            var dao = SharedSqlDao;
            var command = dao.GetDbSprocCommand("WSPX_GoldenTimeCampain_UpdateStatus");
            try
            {
                command.Parameters.Add(dao.CreateParameter("@CampainId", model.Id));
                command.Parameters.Add(dao.CreateParameter("@Status", model.Status));
                command.Parameters.Add(dao.CreateParameter("@Random", model.Random));
                return command.ExecuteNonQuery();
            }
            finally
            {
                command.Connection.Close();
            }
        }
    }
}
